package com.xuan.core.controller.pg;

import com.xuan.core.configuration.result.ResponseResult;
import com.xuan.core.configuration.result.ResponseResultEnum;
import com.xuan.core.dto.pg.PgQiMenDouZhuanXingYiDto;
import com.xuan.core.dto.pg.PgQiMenDto;
import com.xuan.core.service.pg.PgQiMenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 奇门排盘Controller
 */
@RestController
@RequestMapping("/pgQiMen")
public class PgQiMenController {

    @Autowired
    private PgQiMenService pgQiMenService; // 奇门排盘Service

//********************************************************************************************************************************

    /**
     * 开始排盘
     *
     * @param dto 奇门排盘数据接收类
     * @return 排盘结果
     */
    @PostMapping("/starts")
    @Cacheable(
            value = "pgQiMenStarts",
            key = "'_' + #dto.name + #dto.occupy + #dto.sex + #dto.date.year + #dto.date.month + #dto.date.day + #dto.date.hours + " +
                    "#dto.dateType + #dto.address + #dto.leapMonth + #dto.paiPanType + #dto.qiMenType + #dto.yearGanZhiSet + " +
                    "#dto.monthGanZhiSet + #dto.dayGanZhiSet + #dto.hourGanZhiSet + #dto.jieQi + #dto.zhiShi + #dto.renPanFeiZhuan + " +
                    "#dto.renPanZhuanGong + #dto.renPanFeiGong + #dto.tianPanFeiGong + #dto.shenPanFeiGong"
    )
    public ResponseResult<Object> starts(@RequestBody PgQiMenDto dto) {

        Object vo = pgQiMenService.starts(dto);
        return ResponseResult.result(ResponseResultEnum.SUCCESS, vo);

    }

    /**
     * 斗转星移
     *
     * @param dto 奇门斗转星移数据接收类
     */
    @PostMapping("/douZhuanXingYi")
    @Cacheable(
            value = "pgQiMenDouZhuanXingYi",
            key = "'_' + #dto.paiPanType + #dto.jiJie + #dto.hourZhi + #dto.douZhuanXingYiMode + #dto.douZhuanXingYiType + #dto.diPan + " +
                    "#dto.tianPan + #dto.tianPanQiYiToTq + #dto.tianPanQiYiExTq + #dto.renPan + #dto.shenPan + #dto.tianPanQiYi"
    )
    public ResponseResult<Object> douZhuanXingYi(@RequestBody PgQiMenDouZhuanXingYiDto dto) {

        Object vo = pgQiMenService.douZhuanXingYi(dto);
        return ResponseResult.result(ResponseResultEnum.SUCCESS, vo);

    }


}
